package sun.superstring.loop;

public class BreakAndContinueDemo7 {
    public static void main(String[] args) {
        // 目标：理解break和continue的作用
        test1();
        System.out.println("------------------------");
        test2();
    }

    // 1. break是辞职跑路了
    public static void test1() {
        for (int i = 0; i < 10; i++) {
            if (i == 5) { // 跳出循环
                break;
            }
            System.out.println(i);
        }
    }

    // 2. continue是先休息一天
    public static void test2() {
        for (int i = 0; i < 10; i++) {
            if (i == 5) { // 跳出5的循环
                continue;
            }
            System.out.println(i);
        }
    }
}
